---
title: Print preview and document distribution
summary: End-to-end workflow for rendering and distributing legal correspondence/reports via xPression, MSMQ, or SSRS.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-21
operation_id: OP-APP-004
trigger: User selects Print on a legal maintenance screen
---

# Print preview and document distribution

This workflow renders legal correspondence and reports for preview and distributes them either synchronously (SOAP) or asynchronously (MSMQ) via xPression, or via SSRS, using a shared imaging metadata contract.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-APP-004 |
| **Trigger** | User selects "Print" on a maintenance screen, opening `frmPrintPreview.aspx` |
| **Libraries involved** | [SAIF.Services.Printing](../../libraries/saif-services-printing/overview.md), [SAIF.Services.Imaging.Import](../../libraries/saif-services-imaging-import/overview.md) |
| **Screens** | Print Preview screen (`frmPrintPreview.aspx`) |
| **Inputs** | Claim/legal context metadata, selected document/report |
| **Outputs** | Rendered document bytes streamed to the browser, or a queued xPression distribution request |

## Steps

1. User selects "Print" on a maintenance screen; `frmPrintPreview.aspx` is opened as a popup.
2. Code-behind calls [SAIF.Services.Printing](../../libraries/saif-services-printing/overview.md)'s `clsPrint.previewDocument(...)`, which builds an xPression document request.
3. `clsPrint` composes a `clsImageImport` (from [SAIF.Services.Imaging.Import](../../libraries/saif-services-imaging-import/overview.md)) whose `ToString()` emits a newline-delimited key/value metadata block describing the claim/legal context ([BR-APP-005](../business-rules.md#br-app-005-print-preview-depends-on-a-shared-package-and-metadata-contract)).
4. Depending on the call path, `clsPrint` either streams the rendered document bytes back to the browser synchronously (SOAP) or enqueues it via MSMQ for asynchronous xPression distribution.

## Process flow

The following diagram visualizes the print preview and document distribution workflow.

```mermaid
flowchart TD
	Start([User selects Print]) --> S1["frmPrintPreview opens as<br>popup"]
	S1 --> S2["clsPrint.previewDocument<br>builds xPression request"]
	S2 --> S3["clsImageImport.ToString<br>emits metadata block"]
	S3 --> D{"Synchronous or async<br>distribution?"}
	D -->|Synchronous SOAP| S4["Stream rendered document to<br>browser"]
	D -->|Asynchronous| S5["Enqueue via MSMQ for<br>xPression"]
	S4 --> EndOk([Document delivered])
	S5 --> EndOk
```

## Failure and edge-case behavior
- Authorization for `frmPrintPreview` rests entirely on the caller already having produced the report into the session model plus possession of the `__SAIFPID` view ID; there is no explicit resource check on the print preview endpoint itself.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Data model](../data-model.md)

## Sources
- [SAIF.Services.Printing](../../libraries/saif-services-printing/overview.md)
- [SAIF.Services.Imaging.Import](../../libraries/saif-services-imaging-import/overview.md)
- LegalMaintenance web application (LegalMaintenance/*.aspx.vb)
